import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		selectedNode: {},
		selectFormItem: null,
		userFromMainProject: null,
		timeAreaId: '',
		cwId: '',
		formData: {},
		design: {},
		billList: {},
		varifyInvoiceVOList: [],
		invoiceInfo: {
			type: 2,
			parentId: '',
			totalAmount: '',
			varifyInvoiceDTOList: [],
		},
		isDetail: false,
		formId: '',
		readFileList: [],
		sealFileList: [],
		instanceProgress: [],
	},
	mutations: {
		setReadFileList(state, val) {
			state.readFileList = val
		},
		setSealFileList(state, val) {
			state.sealFileList = val
		},
		setInstanceProgress(state, val) {
			state.instanceProgress = val
		},
		setResetting(state) {
			state.varifyInvoiceVOList = []
			state.isDetail = false
			state.billList = {}
			state.cwId = ''
			state.formData = {}
			state.invoiceInfo = {
				type: 2,
				parentId: '',
				totalAmount: '',
				varifyInvoiceDTOList: [],
			}
			state.timeAreaId = ''
		},
		setFormId(state, val) {
			state.formId = val
		},
		setVarifyInvoiceVOList(state, val) {
			state.varifyInvoiceVOList = val
		},
		setIsDetail(state, val) {
			state.isDetail = val
		},
		setBillList(state, val) {
			state.billList = val
		},
		setCwId(state, val) {
			state.cwId = val
		},
		setFormData(state, val) {
			state.formData = val
		},
		selectedNode(state, val) {
			state.selectedNode = val
		},
		setUser(state, val) {
			state.userFromMainProject = val
		},
		setUserInfo(state, val) {
			state.loginUser = val
		},
		loadForm(state, val) {
			state.design = val
		},
		setIsEdit(state, val) {
			state.isEdit = val
		},
		setInvoiceInfo(state, val) {
			state.invoiceInfo[val.type] = val.value
		},
		setTimeAreaId(state, val) {
			state.timeAreaId = val
		},
	},
	getters: {},
	actions: {},
	modules: {},
})
